<template>
  <div class="login-container">
    <div class="login-weaper  animated bounceInDown">
      <div class="login-left">
        <img
          class="img"
          src="/img/logo.png"
          alt=""
        >
        <p class="title">{{website.infoTitle}}</p>
        <!--<p>©2020 v2.8.0</p>-->
      </div>
      <div class="login-border">
        <div class="login-main">
          <h4 class="login-title">
            <el-select
              v-model="active"
              class="login-select animated fadeIn"
              placeholder="点击请选择园区"
              @change="handleCommand"
            >
              <el-option
                v-for="tenant in tenantList"
                :key="tenant.id"
                :label="tenant.name"
                :value="tenant.id"
              ></el-option>
            </el-select>
          </h4>
          <userLogin v-if="activeName==='user'"></userLogin>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { fetchList } from '@/api/admin/tenant'
import '@/styles/login.scss'
import userLogin from "./userlogin";
import { mapGetters } from "vuex";
import store from "@/store"
import { getStore, setStore } from "@/util/store";
import { dateFormat } from "@/util/date";
import { validatenull } from "@/util/validate";
export default {
  name: "login",
  components: {
    userLogin
  },
  data () {
    return {
      tenantList: [],
      activeName: "user",
      socialForm: {},
      active: '',
    };
  },
  watch: {},
  created () {
    // 直接隐藏
    this.getTenantList()
    // setStore({ name: 'tenantId', content: '1' })
    this.active = getStore({ name: 'tenantId' })
  },
  mounted () {
  },
  computed: {
    ...mapGetters(["website"])
  },
  props: [],
  methods: {
    handleCommand (command) {
      setStore({ name: 'tenantId', content: command })

    },
    getTenantList () {
      fetchList().then(response => {
        if (response.data != null && response.data != undefined) {
          this.tenantList = response.data.data
        }
      })
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
